package com.andrew.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.andrew.entity.Cart;
import com.andrew.entity.Customer;
import com.andrew.service.CartService;
import com.andrew.service.CustomerService;
import com.andrew.service.impl.CartServiceImpl;
import com.andrew.service.impl.CustomerServiceImpl;

public class LoginServlet extends HttpServlet{
	
	private CustomerService customerService =new CustomerServiceImpl();
	private CartService cartService=new CartServiceImpl();
	
		@Override
		protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {			
			this.doPost(req,resp);													
			
			
		}
		@Override
		
		
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			req.setCharacterEncoding("UTF-8");
			resp.setContentType("text/html;charset=UTF-8");
			Customer customer= (Customer)req.getSession().getAttribute("customer");
			
			int type=customer.getIsAdmin();
			if(type==1) {		
				resp.sendRedirect("admin/admin.jsp");
			}else if(type==0) {
				resp.sendRedirect("customer.jsp");
				
			}
		}
}
